/**
 * 
 */
package com.swg.cocobox.filetransfer.command;

import com.swg.cocobox.filetransfer.internal.ASCIICommandBuilder;
import com.swg.cocobox.filetransfer.internal.ASCIICommandParser;
import com.swg.cocobox.filetransfer.internal.ASCIIReplyCommandBuilder;
import com.swg.cocobox.filetransfer.internal.ASCIIReplyCommandParser;
import com.swg.cocobox.filetransfer.internal.UTFCommandBuilder;
import com.swg.cocobox.filetransfer.internal.UTFCommandParser;

/**
 * @author satriaprayoga
 *
 */
final public class CommandContext {
	

	/**
	 * Abort File Transfer
	 */
	public static final String ABOR="ABOR";
	/**
	 * Change work directory
	 */
	public static final String CWD="CWD";
	/**
	 * retrieve file
	 */
	public static final String RETR="RETR";
	/**
	 * port information
	 */
	public static final String PORT="PORT";
	/**
	 * information of file
	 */
	public static final String LPTR="LPRT";
	/**
	 * information of size
	 */
	public static final String SIZE="SIZE";
	
	public static final int COMMAND_OK=200;
	
	public static final int FILE_STATUS_OK=213;
	
	public static final int FILE_STATUS_NOK=404;
	
	public static final int DATA_CONN_OPEN=150;
	
	public static final int DATA_CONN_CLOSE=226;
	
	public static final int UNKNOWN_COMMAND=500;
	
	public static final int DEFAULT_DATAPORT=9905;
	
	public static enum CommandEncoding{
		ASCII,UTF_8
	}
	

	public static final ClientCommandFactory getClientCommandFactory(CommandEncoding encoding){
		if(encoding==CommandEncoding.UTF_8)
			return new UTFClientCommandFactory();
		else
			return new ASCIIClientCommandFactory();
	}
	
	public static final ReplyCommandFactory getReplyCommandFactory(CommandEncoding encoding){
		return new ASCIIReplyCommandFactory();
	}
	
	private static class ASCIIClientCommandFactory extends ClientCommandFactory{
		public ASCIIClientCommandFactory() {
			super(new ASCIICommandBuilder(),new ASCIICommandParser());
		}
	}
	
	private static class UTFClientCommandFactory extends ClientCommandFactory{
		public UTFClientCommandFactory() {
			super(new UTFCommandBuilder(),new UTFCommandParser());
		}
	}
	
	private static class ASCIIReplyCommandFactory extends ReplyCommandFactory{
		public ASCIIReplyCommandFactory() {
			super(new ASCIIReplyCommandBuilder(),new ASCIIReplyCommandParser());
		}
	}
	
	
}
